home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / amigadoslibrary / unlock.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  821b  |  43 lines

  1. /* UnLock.c   V1.0   93-03-15                        */
  2. /* ROM library: "dos.library/UnLock", (All versions) */
  3. /* Copyright 1993, Anders Bjerin, Amiga C Club       */
  4.  
  5. #include <dos/dos.h>
  6.  
  7. #include <clib/dos_protos.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. UBYTE *version = "$VER: UnLock 1.0";
  12.  
  13. int main( int argc, char *argv[] );
  14. int main( int argc, char *argv[] )
  15. {
  16.   BPTR my_lock;
  17.  
  18.  
  19.   /* Put an exclusive lock on a file: */
  20.   my_lock = Lock( "RAM:Score.dat", EXCLUSIVE_LOCK );
  21.  
  22.   /* OK? */
  23.   if( !my_lock )
  24.   {
  25.     /* Problems, the file does not exist or someone */
  26.     /* else is using the file:                      */
  27.     printf( "Error! Could not lock the file!\n" );
  28.     exit( 20 );
  29.   }
  30.   else
  31.     printf( "File is locked!\n" );
  32.  
  33.  
  34.   /* - - - */
  35.  
  36.  
  37.   /* Unlock the file: */
  38.   UnLock( my_lock );
  39.  
  40.   exit( 0 );
  41. }
  42.  
  43.